<!DOCTYPE html>
<html lang="en" xmlns:v-on="http://www.w3.org/1999/xhtml">
<head>
    <meta charset="UTF-8">
    <title>v-for和v-if</title>
    <script src="../js/vue-dev.js"></script>
</head>
<body>

    <div id="app_for">
        <!--
            当v-for和v-if作用于用一个节点上时，v-for拥有更高的优先级，
            也就是说，在每个循环中，v-if都会执行；
        -->
        <ol>
            <li v-for="item in items" v-if="item.isDisplay">
                {{item.fruit.name}} => {{item.fruit.price}}
            </li>
        </ol>

        <button @click="checkDisplay">Check Display</button>
        <ul v-if="is">
            <li v-for="item in items">
                {{item}}
            </li>
        </ul>


    </div>

    <script>
        var app_for = new Vue({
            el:'#app_for',

            data:{
                is:true,
                items:[
                    {isDisplay:true,fruit:{name:'apple',price:1.3}},
                    {isDisplay:false,fruit:{name:'banana',price:1.5}},
                    {isDisplay:true,fruit:{name:'pear',price:1.8}},
                ]
            },
            methods:{
                checkDisplay:function () {
                    this.is = !this.is ;
                }
            }
      })

    </script>
</body>
</html>